package com.zhouyu.service;

import com.zhouyu.mini.spring.*;

/**
 * @Author: 01195
 * @Date: 2025/9/9 15:40
 * @Description
 */
@Component("userService")
//@Scope("prototype")
@Lazy(value = false)
public class UserService implements UserInterface, InitializingBean, BeanNameAware {
    public UserService(){
        System.out.println("UserService 无参构造函数执行了");
    }

    @Autowired
    private OrderService orderService;

    private String name;

    @ZhouyuValue("xxx")
    private String test;

    @Override
    public void test(){
        System.out.println(orderService);
        System.out.println("test字段值为:" + test);
        System.out.println("name字段值为:" + name);
    }


    @Override
    public void afterPropertiesSet() {
        // 处理逻辑 spring不能自动复制的属性，我们自己可以比如查数据库
        System.out.println("UserService InitializingBean afterPropertiesSet执行了");
        name = "zhouyu";
    }

    @PostConstruct
    private void postConstruct(){
        System.out.println("UserService PostConstruct postConstruct执行了");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("UserService BeanNameAware setBeanName执行了,beanName:" + name);
    }
}
